Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Objects /
Chapter 4 - Colors and Color-Related Objects / Using Colors and Color-Related Objects


Comparing and Testing Colors

QuickDraw GX provides several functions that allow you to analyze individual color values for various purposes.

Checking for Out-of-Gamut Colors

If you have a color value that you want to test against a given color space or color set, you can use the GXCheckColor function. For example, you can use GXCheckColor to see if a given color is representable on a particular printer. If the color is not directly representable--that is, if it is out of gamut--you could alert the user to that fact. You could also call the GXConvertColor function to mimic the automatic color conversion that would take place in printing, to determine what color the printer would use to represent your given color.

Both GXCheckColor and GXConvertColor require the color space and color profile of the device the color is destined for. To get the color space and color profile of a printer, you can use the GXGetPrinterViewDevice and GXGetViewDeviceBitmap functions.

The GXCheckColor function is described on page 4-57. The GXConvertColor function is described on page 4-60. The GXGetPrinterViewDevice function is described in Inside Macintosh: QuickDraw GX Printing. The GXGetViewDeviceBitmap function is described in the chapter "View-Related Objects" in this book.

Checking Colors for Closeness and Color Space

If you want to compare a user-selected color with the range of colors in a color set,
you can use the GXGetColorDistance function to determine how far the selected color is from any of the colors in the color set. If the selected color is close enough (in color-space distance) to one of the existing colors in the color set, you could call
the GXConvertColor function to change the selected color to that closest color. Alternatively, you could call GXGetColorSetParts and GXSetColorSetParts to add the selected color to the color set or replace another color in the color set with the selected color.

As another example, suppose that you open a document containing shapes of various colors, and you want to save a grayscale version of that document. You might call GXCheckColor on each color in the document, and then GXConvertColor on each color whose color space is not already gxGraySpace. (You might also save the original color information as a tag object attached to each shape or ink, for later restoration.)

The GXGetColorDistance function is described on page 4-58. The GXConvertColor function is described on page 4-60. The GXGetColorSetParts function is described on page 4-75; the GXSetColorSetParts function is described on page 4-76. The GXCheckColor function is described on page 4-57.

Predicting Drawing Results

You can preflight, or predict, the results of a drawing operation by using the GXCombineColor function. You supply a destination color, and GXCombineColor tells you what would happen if a shape using the ink object you specify were drawn to a destination of that color. This function is as much a test of transfer mode as it is of source and destination colors; you can use it to see how, or even if, drawing occurs under the conditions you specify. For example, if you are using the gxMigrateMode transfer mode, you may want to adjust the operand so that the result color exactly equals the source color for a particular destination color. You can call GXCombineColor with different operand values until you get the result you want, and then draw the actual shape. Transfer modes, operands, and source and destination colors are described in the chapter "Ink Objects" in this book.

The GXCombineColor function is described on page 4-59.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996